package cn.lintcode;

/**
 * @author labvi
 * @version 1.0.0
 *  158
 */
public class ValidAnagram {
    public boolean anagram(String s, String t) {
        // write your code here
        char[] char_arr = new char[256];
        for (int i = 0; i< s.length() ;i++ ){
            char a = s.charAt(i);
            char_arr[a]++;
        }
        for(int i = 0;i < t.length();i++){
            char a = t.charAt(i);
            char_arr[a]--;
        }
        for (int i = 0; i < char_arr.length; i++) {
            if (char_arr[i] != 0){
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        ValidAnagram validAnagram = new ValidAnagram();
        System.out.println(validAnagram.anagram("az", "by"));
    }
}
